const Router = require('koa-router')
const { publishComment, updateComment, deleteComment, replyComment, getCommentListByMomentId} = require('../controller/comment.controller')
const { verifyAuth, verifyPermission } = require('../middleware/auth.middleware')

const commentRouter = new Router({ prefix: '/comment' })
// 发表评论
commentRouter.post('/:momentId', verifyAuth, publishComment)
// 修改评论
commentRouter.patch('/:commentId', verifyAuth, verifyPermission('comment'), updateComment)
// 删除评论
commentRouter.delete('/:commentId', verifyAuth, verifyPermission('comment'), deleteComment)

// 对另一个评论进行回复， 需要携带momentId在body中，表示对哪个动态下的评论回复
commentRouter.post('/:commentId/reply', verifyAuth, replyComment)

// 根据动态id获取该动态的评论列表
commentRouter.get('/:momentId', getCommentListByMomentId)

module.exports = commentRouter
